Function.RegisterNamespace("System.Web.EventStrategy");

System.Web.EventStrategy.Redmond=function(){
    // IEventStrategy Methods
    this.Add=function(node,type,handler){
        node.attachEvent(normalizeType(type),handler);
    };

    this.Fire=function(node,type,context){
        type=normalizeType(type);
        var eventObj=document.createEventObject();
        eventObj.type=type;
        var eventContext=context||{};
        if(eventContext.Detail)eventObj.detail=eventContext.Detail;
        if(eventContext.ScreenX)eventObj.screenX=eventContext.ScreenX;
        if(eventContext.ScreenY)eventObj.screenY=eventContext.ScreenY;
        if(eventContext.ClientX)eventObj.clientX=eventContext.ClientX;
        if(eventContext.ClientY)eventObj.clientY=eventContext.ClientY;
        if(eventContext.CtrlKey)eventObj.ctrlKey=eventContext.CtrlKey;
        if(eventContext.AltKey)eventObj.altKey=eventContext.AltKey;
        if(eventContext.ShiftKey)eventObj.shiftKey=eventContext.ShiftKey;
        if(eventContext.MetaKey)eventObj.metaKey=eventContext.MetaKey;
        if(eventContext.Button)eventObj.button=eventContext.Button;
        if(eventContext.RelatedTarget)eventObj.relatedTarget=eventContext.RelatedTarget;
        if(node.fireEvent)node.fireEvent(type,eventObj);
    };
    
    this.Kill=function(event){
        return event.returnValue=false;
    };

    this.Remove=function(node,type,handler){
        node.detachEvent(normalizeType(type),handler);
    };

    this.Suppress=function(event){
        event.cancelBubble=true;
    };

    this.Target=function(event){
        return event.srcElement;
    };

    // IStrategySpecification Members
    this.IsSatisfiedBy=function(candidate){
        return String.Equals("\nfunction attachEvent() {\n    [native code]\n}\n",candidate.attachEvent+'');
    };
    
    // Private Methods
    function normalizeType(type){
        type=type.toString().toLowerCase();
        if(!String.StartsWith(type,"on",true))type="on"+type;
        return type;
    }
};

System.Web.EventStrategy.Redmond.Implement(System.Web.Event.IEventStrategy,"System.Web.EventStrategy.Redmond");
System.Web.EventStrategy.Redmond.Implement(System.Script.Strategy.IStrategySpecification,"System.Web.EventStrategy.Redmond");